#pragma once
#include "..\DXAMLCommon.h"
#include "Base.h"

template<typename T,int COUNT>
class _stack :
	public Base
{
public: 
	_stack(struct IMalloc *);
	virtual ~_stack();
	void reset();
	T * push();
	T * pop();
	T * peek();
	T * operator[](XUINT32);
	XUINT32 size();
	void prepend(T const *, XUINT32);
	void append(T const *, XUINT32);
	void appendEmpty(XUINT32);
	void require(XUINT32);
	void requireAvailable(XUINT32 size);
	void clear();
private: 
	void grow(XUINT32 nRequired);
	char * _pStack;
	XUINT32 _lSize;
	XUINT32 _lCapacity;
	char _data[sizeof(T)*COUNT];
};